//========================================================================
// *作者：海盗猫  主页：ilplay.com
// *脚本：HDMAssetsEvent
// *描述：
// *?2021 MYJL . All rights reserved.
//* ======================================================================
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

namespace HDMCode.Hotfix
{
    public class HDMAssetsEvent : HDMPackageHotfixBase
    {
        [Serializable]
        public class AssetsEvent : UnityEvent { }

        [Serializable]
        public class AssetsBaseEvent : UnityEvent<HDMAssetsHotfix> { }

        [Serializable]
        public class AssetsBoolEvent : UnityEvent<bool> { }

        [Serializable]
        public class AssetsStringEvent : UnityEvent<string> { }

        [Serializable]
        public class AssetsFileEvent : UnityEvent<string, long> { }

        [Serializable]
        public class AssetsErrorEvent : UnityEvent<string, string> { }

        [Serializable]
        public class AssetsInfoEvent : UnityEvent<AssetsDownloadInfo[]> { }

        [Serializable]
        public class AssetsProgressEvent : UnityEvent<int, int, long, long> { }

        /// <summary>
        /// 不需要执行更新时的回调
        /// </summary>
        [SerializeField]
        protected AssetsEvent NotUpdatedEvent = new AssetsEvent();

        /// <summary>
        /// 用于最先的初始化方法
        /// </summary>
        [SerializeField]
        protected AssetsBaseEvent AssetsInitEvent = new AssetsBaseEvent();

        /// <summary>
        /// 检测到需要更新时 
        /// AssetsDownloadInfo: 下载信息
        /// </summary>
        /// <returns>返回是否立即更新</returns>
        [SerializeField]
        protected AssetsInfoEvent NeedUpdatedEvent = new AssetsInfoEvent();

        /// <summary>
        /// 文件开始下载时事件
        /// string:下载名称
        /// long：下载大小
        /// </summary>
        [SerializeField]
        protected AssetsFileEvent DownloadStartEvent = new AssetsFileEvent();

        /// <summary>
        /// 下载主资源进度事件
        /// int:总下载数量
        /// int:当前下载数量
        /// long:总下载大小
        /// long:当前下载大小
        /// </summary>
        [SerializeField]
        protected AssetsProgressEvent DownloadMainProgressEvent = new AssetsProgressEvent();

        /// <summary>
        /// 下载次资源进度事件
        /// int:总下载数量
        /// int:当前下载数量
        /// long:总下载大小
        /// long:当前下载大小
        /// </summary>
        [SerializeField]
        protected AssetsProgressEvent DownloadSubProgressEvent = new AssetsProgressEvent();

        /// <summary>
        /// 下载成功时事件
        /// string:成功的包名
        /// </summary>
        [SerializeField]
        protected AssetsStringEvent DownloaderSucceedEvent = new AssetsStringEvent();

        /// <summary>
        /// 检测校验异常时事件
        /// string:失败的信息
        /// </summary>
        [SerializeField]
        protected AssetsStringEvent VerifyErrorEvent = new AssetsStringEvent();

        /// <summary>
        /// 下载结束时无论成功或失败事件
        /// bool：下载结果
        /// </summary>
        [SerializeField]
        protected AssetsBoolEvent DownloadOverEvent = new AssetsBoolEvent();

        /// <summary>
        /// 下载异常时事件
        /// string:文件名称
        /// string:错误信息
        /// </summary>
        [SerializeField]
        protected AssetsErrorEvent DownloadErrorEvent = new AssetsErrorEvent();

        /// <summary>
        /// 指定热更的资源包名
        /// </summary>
        public string assetspackageName = "";
        /// <summary>
        /// 指定热更的补丁包名
        /// </summary>
        public string scriptPackageName = "";

        /// <summary>
        /// 用于补充的元数据
        /// </summary>
        [SerializeField]
        public List<string> mateDate = default;

        /// <summary>
        /// 用于补充的热数据
        /// </summary>
        [SerializeField]
        public List<string> hotfoxDate = default;

        /// <summary>
        /// 当前资源包
        /// </summary>
        public YooAsset.ResourcePackage AssetsPackage { get; set; }

        /// <summary>
        /// 当前补丁包
        /// </summary>
        public  YooAsset.ResourcePackage ScriptPackage { get; set; }

        /// <summary>
        /// 资源下载地址
        /// </summary>
        public AssetsAddress DowanerAdderss;
    }
}
